trigger CaseTrigger on Case(after update,before insert ,before update,after insert) {
    new Triggers()
    .bind(Triggers.Evt.beforeinsert, new CaseHandler())
    .bind(Triggers.Evt.afterinsert, new CaseHandler())
    .bind(Triggers.Evt.beforeupdate, new OnlyTeamLeaderCanUpdateEngineerHandler())
    //.bind(Triggers.Evt.afterinsert, new CaseSmsHandler())
    .bind(Triggers.Evt.beforeupdate, new CaseHandler())
    .bind(Triggers.Evt.afterupdate, new CaseHandler())
    //.bind(Triggers.Evt.afterinsert, new CaseWeixinHandler())
   // .bind(Triggers.Evt.afterupdate, new CaseWeixinHandler())
    .manage();

    if(Trigger.isBefore && trigger.isInsert)CaseToWorkOrderHandler.matchOnwer(Trigger.new);

     if (Trigger.isAfter && Trigger.isInsert) {
       // CaseSmsHandler.sendSmsInfo(Trigger.new, null);
        CaseToWorkOrderHandler.genWorkOrder(Trigger.new,null,trigger.isInsert,trigger.isUpdate);
        CaseToWorkOrderHandler.caseSendMail(trigger.new);
        CaseToWorkOrderHandler.backToServicePlan(trigger.new);
     }
     if (Trigger.isBefore && Trigger.isUpdate) {
        // CaseSmsHandler.sendSmsInfo(Trigger.new, Trigger.oldMap);
       System.debug('***改变记录类型');
        CaseToWorkOrderHandler.changeInstallCaseRecordType(Trigger.new, Trigger.oldMap);
        CaseToWorkOrderHandler.updateWorkOrder(Trigger.new,Trigger.oldMap);
        CaseToWorkOrderHandler.validateCloseCase(Trigger.new, trigger.oldMap);
        CaseToWorkOrderHandler.autoCloseCase(Trigger.new, trigger.oldMap);

        CaseToWorkOrderHandler.caseStatusRecordTime(Trigger.new,Trigger.oldMap);
        CaseToWorkOrderHandler.checkEngneerCloseCase(Trigger.new, Trigger.oldMap);
     }

     if(Trigger.isAfter && Trigger.isUpdate){
      
      
        CaseToWorkOrderHandler.genWorkOrder(Trigger.new,trigger.oldMap,trigger.isInsert,trigger.isUpdate);
         System.debug('***生成工单');
        CaseToWorkOrderHandler.forbidUpdate(trigger.new,trigger.oldMap);
        CaseToWorkOrderHandler.backToServicePlan(trigger.new);
     }
    
}